Skip to content

feat: support MCP tool hints mapped to ToolAnnotations#239

Merged
eskenazit merged 1 commit intomainfrom
feat/mcp-annotations
Apr 8, 2026
Merged

feat: support MCP tool hints mapped to ToolAnnotations#239
eskenazit merged 1 commit intomainfrom
feat/mcp-annotations

Conversation

@jlouvel
Copy link
Copy Markdown
Contributor

@jlouvel jlouvel commented Apr 3, 2026


Related Issue

Closes #200


What does this PR do?

Adds support for MCP tool hints — optional behavioral metadata on tools that maps to ToolAnnotations in the MCP protocol (spec 2025-11-25).

Capability authors can now declare hints on any MCP tool with four advisory properties:

  • readOnly — tool does not modify its environment
  • destructive — tool may perform destructive updates
  • idempotent — repeating the call has no additional effect
  • openWorld — tool interacts with external entities

These are YAML-facing names (no Hint suffix — the hints parent provides context). On the wire, they map to the MCP spec field names (readOnlyHint, destructiveHint, etc.) inside the annotations object.

The existing label field continues to map to both Tool.title and annotations.title.

Example YAML:

tools:
  - name: get-current-weather
    description: "Retrieve current weather conditions"
    hints:
      readOnly: true
      openWorld: true
    call: weather-api.get-current

Changes by layer:

  • Schema: new McpToolHints definition + hints property on McpTool
  • Spec POJO: new McpToolHintsSpec class + hints field on McpServerToolSpec
  • Engine: McpServerAdapter.buildMcpTool() maps hints → McpSchema.ToolAnnotations; ProtocolDispatcher.handleToolsList() emits annotations in the wire response
  • Docs: Specification-Schema, Tutorial Part 1, FAQ, design-guidelines, wrap-api-as-mcp, SKILL.md
  • Example: skill-adapter.yml updated with hints on get-current-weather

Tests

  • McpToolHintsIntegrationTest (7 tests):

    • YAML deserialization of partial and full hints
    • Backward compat: tool without hints has null spec
    • buildToolAnnotations() mapping: hints + label, label-only, neither
    • Wire format roundtrip: tools/list response includes annotations with correct MCP field names, omits absent hints, omits annotations entirely when no hints or label
  • All 395 existing tests pass (0 failures, 0 errors).


Checklist

  • CI is green (build, tests, schema validation, security scans)
  • Rebased on latest main
  • Small and focused — one concern per PR
  • Commit messages follow Conventional Commits

Agent Context (optional)

agent_name: GitHub Copilot
llm: Claude Opus 4.6
tool: VS Code Chat
confidence: high
source_event: user request to support MCP ToolAnnotations per spec 2025-11-25
discovery_method: user_report
review_focus: McpServerAdapter.java:155-180, ProtocolDispatcher.java:146-192, naftiko-schema.json (McpToolHints def)

@jlouvel jlouvel requested a review from eskenazit April 3, 2026 19:38
@jlouvel jlouvel self-assigned this Apr 3, 2026
@jlouvel jlouvel force-pushed the feat/mcp-annotations branch from b835b79 to 5369009 Compare April 3, 2026 19:38
@jlouvel jlouvel mentioned this pull request Apr 4, 2026
4 tasks
@eskenazit
Copy link
Copy Markdown
Contributor

@jlouvel there are conflicts in the branch, can you please solve them for review?

@jlouvel
Copy link
Copy Markdown
Contributor Author

jlouvel commented Apr 7, 2026

@eskenazit Done!

@eskenazit
Copy link
Copy Markdown
Contributor

@jlouvel there are newer conflicts in the branch, can you please solve them for review? ^^'

@jlouvel jlouvel force-pushed the feat/mcp-annotations branch from 5369009 to dc5ee84 Compare April 7, 2026 16:33
@jlouvel
Copy link
Copy Markdown
Contributor Author

jlouvel commented Apr 7, 2026

@eskenazit Should be good now!

@eskenazit eskenazit force-pushed the feat/mcp-annotations branch from dc5ee84 to a8a5b39 Compare April 8, 2026 09:59
Copy link
Copy Markdown
Contributor

@eskenazit eskenazit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@eskenazit eskenazit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eskenazit eskenazit merged commit 6389b2c into main Apr 8, 2026
5 checks passed
@eskenazit eskenazit deleted the feat/mcp-annotations branch April 8, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Framework : MCP Adapter - Add tool annotations (readOnly, destructive, idempotent, openWorld)

2 participants